﻿/*
 * Copyright 2008 Pimm Hogeling, Karim Sempel and Demian Sempel
 * 
 * This file is part of 8bitplays.
 * 
 * 8bitplays is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * 8bitplays is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with 8bitplays. If not, see <http://www.gnu.org/licenses/>.
 */
package nl.sandmen.team.gui {
	import flash.display.NativeWindow;
	import flash.display.NativeWindowInitOptions;
	import flash.display.Screen;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	import nl.sandmen.team.fonts.Fonts;
	import nl.sandmen.team.tools.GradientTool;
	/**
	 * @author Team Sandmen
	 */
	public class AboutWindow extends NativeWindow {
		private var infoField:TextField;
		public function AboutWindow(versionString:String):void {
			var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
			initOptions.maximizable = false;
			initOptions.resizable = false;
			super(initOptions);
			title = "About 8bitplays " + versionString;
			var bounds:Rectangle = Screen.mainScreen.visibleBounds;
			width = 600;
			height = 268;
			x = (bounds.width * .5) - (width * .5);
			y = (bounds.height * .5) - (height * .5);
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.addChild(GradientTool.createGradientBackgroundSprite(0, 0, stage.stageWidth, stage.stageHeight));
			stage.addChild(GradientTool.createGradientFieldSprite(16, 16, stage.stageWidth - 32, stage.stageHeight - 32));
			infoField = new TextField();
			infoField.wordWrap = true;
			infoField.selectable = false;
			infoField.defaultTextFormat = new TextFormat(Fonts.BN_MACHINE, 12, 0x222222, false, false, false, null, null, TextFormatAlign.JUSTIFY);
			infoField.embedFonts = true;
			infoField.width = stage.stageWidth - 40;
			infoField.height = stage.stageHeight - 40;
			infoField.x = 20;
			infoField.y = 20;
			infoField.text = "8bitplays - Copyright 2008 Pimm Hogeling, Karim Sempel and Demian Sempel\n"
			+ "We lead a webdevelopment team called Team Sandmen, you can find us at team.sandmen.nl, hire us if you need some Flash, Flex, AIR or Ruby on Rails work done!\n"
			+ "This project is hosted on Google Code, see air-8bitplays.googlecode.com\n\n"
			+ "8bitpeoples is free software, and you are welcome to redistribute it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.\n\n"
			+ "This program comes with ABSOLUTELY NO WARRANTY, for details see the GNU General Public License.\n\n"
			+ "You can get a copy of the GNU General Public License along with the source on our Google Code page, or from gnu.org/licenses/";
			var teamSandmenFormat:TextFormat = new TextFormat(Fonts.BN_MACHINE, 12, 0x444422, false, false, true, "http://team.sandmen.nl/", null, TextFormatAlign.JUSTIFY);
			var googleCodeFormat:TextFormat = new TextFormat(Fonts.BN_MACHINE, 12, 0x444422, false, false, true, "http://air-8bitplays.googlecode.com/", null, TextFormatAlign.JUSTIFY);
			var gplFormat:TextFormat = new TextFormat(Fonts.BN_MACHINE, 12, 0x444422, false, false, true, "http://gnu.org/licenses/", null, TextFormatAlign.JUSTIFY);
			const teamSandmenStart:int = infoField.text.search("team.sandmen.nl");
			infoField.setTextFormat(teamSandmenFormat, teamSandmenStart, teamSandmenStart + 15);
			const googleCodeStart:int = infoField.text.search("air-8bitplays.googlecode.com");
			infoField.setTextFormat(googleCodeFormat, googleCodeStart, googleCodeStart + 28);
			const gplStart:int = infoField.text.search("gnu.org/licenses/");
			infoField.setTextFormat(gplFormat, gplStart, gplStart + 17);
			stage.addChild(infoField);
			visible = true;
		}
	}
}